package dao;

import org.hibernate.Session;
import org.hibernate.Transaction;

import domain.Address;

import util.HibernateUtil;

public class DAOAddress {

	public Address addAddress(final String street,
								final String city,
								final String zip,
								final String country){
		try{
			Session session = HibernateUtil.getSessionFactory().openSession();
			Transaction tx = session.beginTransaction();
			
			Address add = new Address();
			add.setStreet(street);
			add.setCity(city);
			add.setZip(zip);
			add.setCountry(country);
			
			session.persist(add);
			tx.commit();
			return add;
		}catch(Exception e){
			return null;
		}
		
	}
	
	public boolean updateAddress(final Long id,
			final String street,
			final String city,
			final String zip,
			final String country){
		
		return true;
	}
	
	public boolean removeAddress(final Long id){
		return true;
	}
	
	public Address searchAddress(final Long id){
		return new Address();
	}
}
